package com.zzy.demo.common.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

/**
 * 性别枚举
 * @author liweibo
 * @since 2022-12-08
 */
public enum SexEnum implements IEnum<String> {

    /**
     * 男
     */
    MALE("1", "男"),

    /**
     * 女
     */
    FEMALE("2", "女");
    private String value;
    private String meaning;

    private static final Map<String, SexEnum> ENUMS = new HashMap<>();
    static {
        for (SexEnum aEnum : SexEnum.values()) {
            ENUMS.put(aEnum.getValue(), aEnum);
        }
    }

    @JsonCreator
    public static SexEnum resolve(String value) {
        return ENUMS.get(value);
    }

    SexEnum(String value, String meaning) {
        this.value = value;
        this.meaning = meaning;
    }



    @JsonValue
    @Override
    public String getValue() {
        return value;
    }

    public String getMeaning() {
        return meaning;
    }

}
